package ru.agiledev.client;


import ru.agiledev.aos.commons.dto.LightWord;
import ru.agiledev.wikiservice.LWord;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;

/**
 * Created by a.kirillov
 * Date: 11/14/11 Time: 7:51 PM
 */
public class WikiReader {
     URL url;

    public WikiReader(String wsAddress) throws MalformedURLException {
        this.url = formURL(wsAddress);
    }

    private URL formURL(String address) throws MalformedURLException {
        URL url = new URL(address);
        return url;
    }

    public LightWord getStemmedWord(String word){

        LWord lWord = WSInstanceManager.getServiceInstance(url).getStemmedWord(word);
        if(lWord==null) return null;



        HashSet<String> stemSet = new HashSet<String>();
        stemSet.addAll(lWord.getStems());
        LightWord lightWord = new LightWord(lWord.getValue(), stemSet);

        return lightWord;
    }
}
